package com.example.nutritionmate.repository;

import com.example.nutritionmate.entity.MealRecord;
import com.example.nutritionmate.entity.User;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;

@Repository
public interface MealRecordRepository extends JpaRepository<MealRecord, Long> {
    @EntityGraph(attributePaths = {"meal", "mealNutrition.nutritionFact"})
    List<MealRecord> findByUser(User user);
    @EntityGraph(attributePaths = {"meal", "mealNutritions.nutritionFact"})
    List<MealRecord> findByUserAndMeal_Date(User user, LocalDate date);

}